package com.eas.web.common.chart;

import java.text.MessageFormat;

import org.apache.commons.lang.StringUtils;

public class StackBarValueNode {

    public static final String FULL_FORMAT_PATTERN = "'{'\"val\":{0}, \"tip\":\"{1}\"'}'";

    public String value;

    public String tip;

    public String getTip() {
        return tip;
    }

    public void setTip(String tip) {
        this.tip = tip;
    }

    public String getValue() {
        return value;
    }

    public void setValue(long value) {
        this.value = String.valueOf(value);
    }

    public void setValue(int value) {
        this.value = String.valueOf(value);
    }

    public void setValue(float value) {
        this.value = String.valueOf(value);
    }

    public String toString() {
        if (value != null) {
            if (tip != null)
                return MessageFormat.format(FULL_FORMAT_PATTERN, StringUtils.trimToEmpty(value),
                        StringUtils.trimToEmpty(tip));
            else {
                return value;
            }
        } else {
            return StringUtils.EMPTY;
        }
    }

    public String render() {
        return toString();
    }
}
